package com.example.chao.myphotosearch.adapters.holders;

import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.chao.myphotosearch.R;
import com.example.chao.myphotosearch.dao.Recommend;
import com.example.chao.myphotosearch.dao.RecommendContent;
import com.example.chao.myphotosearch.widget.LinearCardView;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by chao on 2016/3/24.
 */
public class MainViewHolder extends BaseViewHolder<Recommend>{
    @Bind(R.id.tip_title)
    TextView tipTitle;
    @Bind(R.id.tip)
    RelativeLayout tip;
    @Bind(R.id.card_LCV1)
    LinearCardView cardLCV1;
    @Bind(R.id.card_LCV2)
    LinearCardView cardLCV2;
//    @Bind(R.id.refresh_Btn)
//    Button refreshBtn;
    private List<RecommendContent> recommendContents;
    public MainViewHolder(ViewGroup parent) {
        super(parent, R.layout.main_recycler_item);
        ButterKnife.bind(this, itemView);
    }

    @Override
    public void setData(Recommend data) {
        tip.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.e("aaa", "aaa");
            }
        });
        tipTitle.setText(data.getType());
        recommendContents = data.getRecommendContents();
        if(recommendContents.isEmpty()||recommendContents==null){
            return;
        }
        cardLCV1.setCardView(recommendContents,0);
        if(recommendContents.size()>2){
            cardLCV2.setCardView(recommendContents,1);
            cardLCV2.setVisibility(View.VISIBLE);
        }else {
            cardLCV2.setVisibility(View.GONE);
        }
//        title.setText(data.getType());
//        refreshBtn.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                Log.e("bbb", "bbb");
//            }
//        });
    }

}